<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" placeholder="输入姓名" v-model="keyWord">
        <ul>
            <li v-for="star in result" :key="star.id">
                {{star.name}} - {{star.age}} - {{star.sex}}
            </li>
        </ul>
        <!-- 
            vue对已知的列表进行过滤
            字符串indexof空串 等到的是0  不是-1
        -->
    </div>
    <script src="../vuejs/vue.js"></script>
    <script>
        const vm = new Vue({
            el : '#app',
            data() {
                return {
                    stars: [{
                        id : 001,
                        name : "周冬雨",
                        age : 22,
                        sex : "女"
                    },{
                        id : 002,
                        name : "马冬梅",
                        age : 24,
                        sex : "女"
                    },{
                        id : 003,
                        name : "周杰伦",
                        age : 23,
                        sex : "男"
                    },{
                        id : 004,
                        name : "周杰",
                        age : 40,
                        sex : "男"
                    }],
                    keyWord : ''
                }
            },
            computed : {
                result:{
                    get(){
                        console.log("this",this);
                        return this.stars.filter(item => {
                            console.log("this.star",item.name,this.keyWord);
                            return item.name.includes(this.keyWord)
                        });
                    }
                }
            }
        })
    </script>
</body>
</html>